package com.offcn.login;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
//日期工具类
//做字符串转日期，日期转字符串的操作
public class DateUtil {
    //将字符串转为日期类型
    public static Date dateformat(String s){
        SimpleDateFormat sdf = new SimpleDateFormat("YY-MM-dd");
        try {
            return sdf.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
            throw new RuntimeException();
        }

    }
    //将日期类型转为字符串
    public static String format(Date d){
        SimpleDateFormat sdf = new SimpleDateFormat("YY-MM-dd");
        try {
            return sdf.format(d);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException();
        }

    }

}
